<?xml version="1.0" encoding="ISO-8859-1" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
    <jsp:directive.page language="java"
        contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" />
    <jsp:text>
        <![CDATA[ <?xml version="1.0" encoding="ISO-8859-1" ?> ]]>
    </jsp:text>
    <jsp:text>
        <![CDATA[ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> ]]>
    </jsp:text>
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page import="au.edu.unsw.editingtool.global.EditingToolGlobalConstant" %>
<%@ page import="au.edu.unsw.editingtool.global.EditingToolUtil" %>
<%@ page import="java.util.Hashtable" %>
<%@ page import="java.util.Enumeration" %>
<% 
String title=EditingToolUtil.getHTTPRequestData(request, "pubTitle");
String message=EditingToolUtil.getHTTPRequestData(request, "pubMessage");
String buttonName=EditingToolUtil.getHTTPRequestData(request, "pubButton");
String readonly=EditingToolUtil.getHTTPRequestData(request, "pubReadonly");
String action=EditingToolUtil.getHTTPRequestData(request, EditingToolGlobalConstant.requestFormAction);
String command=EditingToolUtil.getHTTPRequestData(request, EditingToolGlobalConstant.requestCommandType);
String pid=EditingToolUtil.getHTTPRequestData(request, EditingToolGlobalConstant.requestPid);
%>
<head>
<link href="css/edit.css" 
        rel="stylesheet" type="text/css" />
<script src="js/lib.js" language="javascript" type="text/javascript" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title><%=title %></title>
</head>
<body>
<form name="edit_form" method="post" action="<%=action %>" enctype="multipart/form-data" onsubmit="javascript:return validate();">
<%
Hashtable<String, String> formData = new Hashtable<String, String>();
if (request.getAttribute(EditingToolGlobalConstant.requestFormData) != null) {
	formData = (Hashtable) request.getAttribute(EditingToolGlobalConstant.requestFormData);
} else {
	String element = "";
	for (Enumeration<String> e = request.getParameterNames(); e.hasMoreElements(); ) {
		element = (String) e.nextElement();
		if (element.equals(EditingToolGlobalConstant.requestCommand))
			continue;
		else if (element.equals(EditingToolGlobalConstant.requestSessionID))
			continue;
		else if (element.equals(EditingToolGlobalConstant.requestUsername))
			continue;
		else if (element.equals("pubTitle"))
			continue;
		else if (element.equals("pubMessage"))
			continue;
		else if (element.equals("pubButton"))
			continue;
		else if (element.equals("pubReadonly"))
			continue;
		else if (element.equals(EditingToolGlobalConstant.requestFormAction))
			continue; 
		else if (element.equals(EditingToolGlobalConstant.requestCommandType))
			continue;
		else if (element.equals("submit"))
			continue;
		else if (element.equals("cancel"))
			continue;
		else {
			formData.put(element, request.getParameter(element));
		}
	}
}
Enumeration<String> items = formData.keys();
while (items.hasMoreElements()) {
	String key = (String) items.nextElement();
	String label = EditingToolUtil.transformAsLabel(key);
	String value = formData.get(key);
	%>
	<label><%=label %></label>
	<textarea name="<%=key %>" rows="2" cols="45" <%=readonly %>="<%=readonly %>"><%=value %></textarea>
<%
}
%>
<% if (request.getParameter(EditingToolGlobalConstant.requestSessionID) == null) { %>
<input type="hidden" name="<%=EditingToolGlobalConstant.requestSessionID %>" value="<%=request.getSession().getId() %>" />
<% } else { %>
<input type="hidden" name="<%=EditingToolGlobalConstant.requestSessionID %>" value="<%=request.getParameter(EditingToolGlobalConstant.requestSessionID) %>" />
<% } %>
<input type="hidden" name="<%=EditingToolGlobalConstant.requestUsername %>" value="<%=request.getParameter(EditingToolGlobalConstant.requestUsername) %>" />

<% if (command.equals(EditingToolGlobalConstant.commandEdit)) {  %>
<input type="hidden" name="pubTitle" value="Preview Publication" />
<input type="hidden" name="pubMessage" value="Preview your edited publication information before submiting." />	
<input type="hidden" name="pubButton" value="<%=EditingToolGlobalConstant.buttonTypeSubmit %>" />
<input type="hidden" name="pubReadonly" value="readonly" />
<input type="hidden" name="<%=EditingToolGlobalConstant.requestFormAction %>" value="FormCommit" />
<input type="hidden" name="<%=EditingToolGlobalConstant.requestCommandType %>" value="<%=EditingToolGlobalConstant.commandPreview %>" />
<% } %>
<input type="hidden" name="<%=EditingToolGlobalConstant.requestPid %>" value="<%=pid %>" />
<input type="submit" name="<%=buttonName %>" value="<%=buttonName %>" />
<input type="submit" name="cancel" value="cancel" />
</form>
</body>
</html>
</jsp:root>